@import '_variables';
@import '_wrapper';

$mobileSidebarWidth: $sidebarWidth * 0.82;

.page {
  padding-left: $sidebarWidth;
}

.navbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: $navbarHeight;
  background-color: #fff;
  box-sizing: border-box;
  border-bottom: 1px solid $borderColor;
}

.sidebar {
  font-size: 16px;
  background-color: #fff;
  width: $sidebarWidth !important;
  position: fixed;
  z-index: 10;
  margin: 0;
  top: $navbarHeight;
  left: 0;
  bottom: 0;
  box-sizing: border-box;
  border-right: 1px solid $borderColor;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: $accentColor $borderColor;
  &::-webkit-scrollbar {
    width: 7px;
  }
  &::-webkit-scrollbar-track {
    background-color: $borderColor;
  }
  &::-webkit-scrollbar-thumb {
    background-color: $accentColor;
  }
}

.sidebar-mask {
  position: fixed;
  z-index: 9;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
}

.theme-container {
  &.sidebar-open {
    .sidebar-mask {
      display: block;
    }
  }

  &.no-navbar {
    #{$contentClass}:not(.custom) > h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
      margin-top: 1.5rem;
      padding-top: 0;
    }

    .sidebar {
      top: 0;
    }
  }
}

@media (min-width: ($MQMobile + 1px)) {
  .theme-container.no-sidebar {
    .sidebar {
      display: none;
    }

    .page {
      padding-left: 0;
    }
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  #{$contentClass}:not(.custom) > & {
    margin-top: 0.5rem - $navbarHeight;
    padding-top: ($navbarHeight + 1rem);
    margin-bottom: 0;

    &:first-child {
      margin-top: -1.5rem;
      margin-bottom: 1rem;

      + p,
      + pre,
      + .custom-container {
        margin-top: 2rem;
      }
    }
  }
}

#{$contentClass}:not(.custom) {
  @extend %wrapper;

  > *:first-child {
    margin-top: $navbarHeight;
  }

  a:hover {
    text-decoration: underline;
  }

  p.demo {
    padding: 1rem 1.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  img {
    max-width: 100%;
  }
}

#{$contentClass}.custom {
  padding: 0;
  margin: 0;

  img {
    max-width: 100%;
  }
}

// narrow desktop / iPad
@media (max-width: $MQNarrow) {
  .sidebar {
    font-size: 15px;
    width: $mobileSidebarWidth;
  }

  .page {
    padding-left: $mobileSidebarWidth;
  }
}

// wide mobile
@media (max-width: $MQMobile) {
  .sidebar {
    top: 0;
    padding-top: $navbarHeight;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .page {
    padding-left: 0;
  }

  .theme-container {
    &.sidebar-open {
      .sidebar {
        transform: translateX(0);
      }
    }

    &.no-navbar {
      .sidebar {
        padding-top: 0;
      }
    }
  }
}

// narrow mobile
@media (max-width: $MQMobileNarrow) {
  h1 {
    font-size: 1.9rem;
  }
}
